﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ControlCustomizition
{
        public partial class MainWindow : Window
        {
                public MainWindow()
                {
                        InitializeComponent();
                }

                internal void PlayMaskPersonalSignatureAnimation(double toValue)
                {
                        DoubleAnimation doubleAnimation = new DoubleAnimation();
                        doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.2));
                        doubleAnimation.To = toValue;
                        Mask_PersonalSignature.BeginAnimation(OpacityProperty, doubleAnimation);
                }

                internal void PlayMaskRoleAnimation(double toValue)
                {
                        DoubleAnimation doubleAnimation = new DoubleAnimation();
                        doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.2));
                        doubleAnimation.To = toValue;
                        PART_MaskRole.BeginAnimation(OpacityProperty, doubleAnimation);
                }

                private void PART_PersonalSignature_MouseEnter(object sender, MouseEventArgs e)
                {
                        PlayMaskPersonalSignatureAnimation(0.5);
                }

                private void PART_PersonalSignature_MouseLeave(object sender, MouseEventArgs e)
                {
                        PlayMaskPersonalSignatureAnimation(0);
                }

                private void PART_MaskRole_MouseEnter(object sender, MouseEventArgs e)
                {
                        PlayMaskRoleAnimation(0.5);
                }

                private void PART_MaskRole_MouseLeave(object sender, MouseEventArgs e)
                {
                        PlayMaskRoleAnimation(0);
                }

                private void PART_MaskRole_MouseDown(object sender, MouseButtonEventArgs e)
                {
                        OpenFileDialog openFileDialog = new OpenFileDialog();
                        openFileDialog.Filter = "图片|*.png;*.jpg;*.webp";
                        if (openFileDialog.ShowDialog() == true)
                        {
                                RoleImage.ImageSource = new BitmapImage(new Uri(openFileDialog.FileName));
                        }
                }

                private void PART_ChangeBackgroundImage_Click(object sender, RoutedEventArgs e)
                {
                        OpenFileDialog openFileDialog = new OpenFileDialog();
                        openFileDialog.Filter = "图片|*.png;*.jpg;*.webp";
                        if(openFileDialog.ShowDialog() == true)
                        {
                                PART_BackgroundImage.ImageSource = new BitmapImage(new Uri(openFileDialog.FileName));
                        }
                }
        }
}
